import 'package:flutter/material.dart';
import 'package:hxdj/common/colors/my_colors.dart';

///边框组件
class MyBorder extends StatelessWidget {
  static BoxDecoration defaultDecoration = BoxDecoration(
    color: Colors.white,
    borderRadius: BorderRadius.circular(8),
    border: Border.all(color: MyColours.color2E2626),
    boxShadow: [
      BoxShadow(
        color: Colors.black.withOpacity(0.1),
        offset: const Offset(0, 2),
        blurRadius: 12,
        spreadRadius: 0,
      )
    ],
  );

  const MyBorder({
    super.key,
    required this.child,
    this.color = const Color(0xffffffff), //边框线颜色
    this.width = 0, //边框线宽度
    this.radius = 8.0, //圆角
    this.backgroundColor = const Color(0xffffffff), //内容背景颜色
    this.border, //边框
    this.blurRadius, //模糊半径
    this.rightOffset = 4, //右偏移量
    this.shadowColor, //阴影颜色
    this.decoration,
  });

  final Widget child;
  final Color color;
  final double width;
  final double radius;
  final Color backgroundColor;
  final Border? border;
  final double? blurRadius;
  final double rightOffset;
  final Color? shadowColor;
  final BoxDecoration? decoration;

// element = BoxDecoration(
//   color: Colors.white,
//   borderRadius: BorderRadius.circular(8),
//   border: Border.all(color: MyColours.color2E2626),
//   boxShadow: [
//     BoxShadow(
//       color: Colors.black.withOpacity(0.1),
//       offset: const Offset(0,2),
//       blurRadius: 12,
//       spreadRadius: 0,
//     )
//   ],
// );

  @override
  Widget build(BuildContext context) {
    return DecoratedBox(
      decoration: decoration ??
          BoxDecoration(
              color: backgroundColor,
              //设置四周圆角 角度
              borderRadius: BorderRadius.circular(radius),
              //设置四周边框
              border: border ?? Border.all(width: width, color: color),
              boxShadow: [
                BoxShadow(
                  blurRadius: blurRadius ?? 10,
                  color: shadowColor ?? MyColours.color2E2626,
                  //向右下偏移的距离
                  offset: Offset(0, rightOffset),
                )
              ]),
      child: child,
    );
  }
}
